import { computed, defineComponent, ref, watch } from 'vue';
import { useConfig } from './config';
import { getJobTriggerList } from '@/api/system/job';
import { VxeBasicTable } from '@/components/VxeTable';

const params = {
  jobId: {
    type: [Number, String],
    require: true,
    default: () => {
      return 0;
    }
  },
  triggerData: {
    type: Array,
    require: true,
    default: () => {
      return [];
    }
  },
  visible: {
    type: Boolean,
    require: true,
    default: () => {
      return false;
    }
  }
};
export default defineComponent({
  name: 'SysJobTrigger',
  props: params,
  emits: ['update:visible'],
  setup(props, { emit }) {
    const getBindValues = computed(() => {
      return {
        ...props
      };
    });
    const { jobId, triggerData } = getBindValues.value;
    // 是否是修改
    const isUpdate = ref(false);
    // 提交状态
    const loading = ref(false);
    const { TableRef, DefaultWhere, ToolBtn, Action, options } =
      useConfig(getJobTriggerList);
    DefaultWhere.value.JobId = jobId;
    const handleEdit = () => {};
    const handleDelete = () => {};
    /* 更新visible */
    const updateVisible = (value: boolean) => {
      emit('update:visible', value);
    };
    const save = () => {};
    watch(
      () => props.visible,
      () => {}
    );
    return () => {
      return (
        <VxeBasicTable ref={TableRef} {...options}>
          {{
            toolbar_buttons() {},
            action({ row }) {
              return [
                <Action
                  record={row}
                  onEdit={handleEdit}
                  onDelete={handleDelete}
                />
              ];
            }
          }}
        </VxeBasicTable>
      );
    };
  }
});
